package org.nanotek.tika.tests.mq.send;

import java.text.DateFormat;
import java.text.ParseException;
import java.util.Date;
import java.util.Formatter;

import javax.swing.text.DateFormatter;

import org.nanotek.cms.domain.lucene.BaseDocument;
import org.nanotek.cms.domain.message.BodyMessageContainer;
import org.nanotek.cms.domain.message.MessageType;
import org.nanotek.mq.send.MetaIndexerSenderService;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class BaseDocumentQueueSenderTest {

	private static ClassPathXmlApplicationContext ctx;

	public BaseDocumentQueueSenderTest() {
	}

	/**
	 * @param args
	 * @throws InterruptedException 
	 * @throws ParseException 
	 */
	public static void main(String[] args) throws InterruptedException, ParseException {
		ctx = new ClassPathXmlApplicationContext(new String[] {"activemq-config/base-activemq-sender-context.xml"});
		MetaIndexerSenderService sender =  (MetaIndexerSenderService) ctx.getBean("metaIndexerSenderService");
		Long startDate = new Date().getTime();
		int i = 0 ;
		for ( i = 0 ; i < 1000 ; i++){
			BodyMessageContainer msgContainer = new BodyMessageContainer();
			msgContainer.setId(new Date().getTime());
			msgContainer.setMessageType(MessageType.DocumentCreate);
			BaseDocument baseDocument = new BaseDocument();
			baseDocument.setId("This is the BaseDocumentID");
			baseDocument.setContent("This is the Base document content " + i + " " + new Date().getTime());
			baseDocument.setReferURL("THIS IS THE REFER URL " + i + " " + new Date().getTime());
			msgContainer.setBodyMessage(baseDocument);
			sender.sendMessage(msgContainer);
		}
		Long endDate = new Date().getTime();
		endDate = (endDate - startDate)/1000;
		System.out.println("TIME TO SEND MESSAGE " + i + " " + endDate);
		System.exit(0);
	}

}
